package thread;

import sun.misc.GC;

import java.net.SocketTimeoutException;

public class DeamonThreadDemo {
    public static void main(String[] args) {
        System.out.println(Thread.currentThread().getName());
        Thread rose=new Thread("rose"){
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName()+Thread.interrupted());
                for (int i = 0; i < 5; i++) {
                    System.out.println(getName()+":let me go");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println(getName()+":扑通");
            }
        };
        Thread jack=new Thread("jack"){
            @Override
            public void run() {
                while (true){
                    rose.interrupted();
                    System.out.println(getName()+":you jump i jump!");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }


                }
            }
        };



        rose.start();
        jack.setDaemon(true);
        jack.start();
       // while (true);
    }
}
